/**
 * http://usejsdoc.org/
 * 生成server
 */
let ejs = require('../../ejs/ejsUtil.js');
let path=require('path');
let fs=require('fs');
let mutil=require('../../ejs/EjsDataHandler.js');
let fileName=path.resolve(__dirname,"../../../template/server.ejs");


exports.handler=function(data){
	if(selfConfig.test)return ;


	data.orderTable.forEach((item)=>{//循环表
		var table=data.tables[item];
		var arr=[].concat(table.id,table.field);


		if(table){
			ejs.mrenderFile(fileName,{
				tableName:item,
				table:table,
				fields:arr
			},(err,str)=>{
				if(err)console.log(err);
				 // log(str)
				fs.writeFileSync(path.resolve(selfConfig['root'],"src/main/java/priv/mill/server",mutil.toPasic(item)+"Service.java"),str);
			});
		}
		

	});


}


